


' Monitor usb device


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
	Set WMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")



	Set colusb = WMIService.ExecQuery ("Select * from Win32_LogicalDisk where DriveType=2")

Set colMonitoredProcesses = objWMIService. _        
    ExecNotificationQuery("select * from __instancecreationevent " _ 
        & " within 1 where TargetInstance isa 'Win32_LogicalDisk'")
i = 0

Do While i = 0
   Set objLatestProcess = colMonitoredProcesses.NextEvent
	str=objLatestProcess.TargetInstance.Name
	
		Wscript.Echo str
	'	Wscript.Echo objLatestProcess.TargetInstance.PNPDeviceID 
	'		Wscript.Echo objLatestProcess.TargetInstance.VolumeSerialNumber  
		Wscript.sleep 10000
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk where Name=" & "'" & str & "'" ) 
	'	WScript.Echo colItems.count
	For Each objusb in colItems
		Wscript.Echo objusb.Caption
		Wscript.Echo objusb.Description
		Wscript.Echo "FileSystem  : " & objusb.FileSystem  
		WScript.Echo "Free Space : " & (objusb.FreeSpace /1073741824) & " GB"
		Wscript.Echo "PNPDeviceID : " & objusb.PNPDeviceID  
		Wscript.Echo "VolumeSerialNumber : " & objusb.VolumeSerialNumber  
		Wscript.Echo "Size : " & (objusb.Size/1073741824) & "GB" 
		Wscript.Echo "VolumeName : " & objusb.VolumeName  
				Wscript.Echo "DriveType  : " & objusb.DriveType   
	next
Loop


